As the size of a semiconductor memory decreases, a memory system is required to have high degree of error correction performance. In the past, when a decoding device for decoding an error correction code such as BCH code is implemented, circuits corresponding to the maximum number of bits of error correction specified in a system are implemented.